define(['js/init'],function(base) {
	var $$ = Dom7;

	//上传数据
	function uploadData(url,data,callback){
		if('wifi'===checkNetworkStatus()){
			$.ajax({
				url			: url,
				dataType	: 'json',
				type		: 'post',
				data		: {data:encodeURI(JSON.stringify(data))},
				success		: function(data){
					if($.isFunction(callback)){
						callback(data);
					}
				}
				,
				error		: function(error){
					
					if($.isFunction(callback)){
						callback({status:'error'});
					}else{
						alert('数据上传失败...请再次尝试上传.如问题依旧，请联系系统管理员进行处理！')
					}
				}
			})
		}
	}

	//检查网络状态
	function checkNetworkStatus(){
		var networkState = navigator.connection.type;

		return networkState;
	}

	return {
		checkNetworkStatus:checkNetworkStatus,
		uploadData	: uploadData
	};
});